import { IPSApplication } from '../ipsapplication';
import { IPSAppWF } from './ipsapp-wf';
import { IPSAppWFUIAction } from './ipsapp-wfuiaction';
import { IPSAppWFVer } from './ipsapp-wfver';
import { IPSWFVersion } from '../../wf/ipswfversion';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppWFVerImpl extends PSModelObjectImpl implements IPSAppWFVer {
  protected allpsappwfuiactions: IPSAppWFUIAction[] | null = null;

  getAllPSAppWFUIActions(): IPSAppWFUIAction[] | null {
    if (this.allpsappwfuiactions == null) {
      this.allpsappwfuiactions = this.fillChildListModel(this.M.getAllPSAppWFUIActions, 'app.wf.IPSAppWFUIAction') as IPSAppWFUIAction[];
    }
    return this.allpsappwfuiactions;
  }

  get allPSAppWFUIActions(): IPSAppWFUIAction[] | null {
    return this.getAllPSAppWFUIActions();
  }

  findPSAppWFUIAction(objKey: any): IPSAppWFUIAction | null {
    return this.getPSModel5('app.wf.IPSAppWFUIAction', this.getAllPSAppWFUIActions(), objKey) as IPSAppWFUIAction;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappwf: IPSAppWF | null = null;

  getPSAppWF(): IPSAppWF | null {
    if (this.psappwf != null) return this.psappwf;
    const value = this.M.getPSAppWF;
    if (value == null) {
      return null;
    }
    const ipsapplication = this.getParentPSModelObject('app.IPSApplication') as IPSApplication;
    if (ipsapplication != null) {
      this.psappwf = ipsapplication.findPSAppWF(value);
    }
    return this.psappwf;
  }

  get psAppWF(): IPSAppWF | null {
    return this.getPSAppWF();
  }

  getPSAppWFMust(): IPSAppWF {
    const value = this.getPSAppWF();
    if (value == null) {
      throw new Error('未指定应用工作流');
    }
    return value;
  }

  protected pswfversion: IPSWFVersion | null = null;

  getPSWFVersion(): IPSWFVersion | null {
    if (this.pswfversion != null) return this.pswfversion;
    const value = this.M.getPSWFVersion;
    if (value == null) {
      return null;
    }
    this.pswfversion = this.getPSAppWFMust().getPSWorkflowMust().findPSWFVersion(value);
    return this.pswfversion;
  }

  get psWFVersion(): IPSWFVersion | null {
    return this.getPSWFVersion();
  }

  getPSWFVersionMust(): IPSWFVersion {
    const value = this.getPSWFVersion();
    if (value == null) {
      throw new Error('未指定工作流版本');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSAppWFVerImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.wf.IPSAppWFVer') return true;
    return super.instanceof(cls);
  }
}
